package com.eralink.readerfinderlib;

class Processor {
    private int cmdCode;
    private String description;
    private RequestValidator requestValidator;
    private Requestor requestor;
    private boolean needNotifyRequestor = true;
    private ResponseValidator responseValidator;
    private ResponseUtilizer responseUtilizer;
    private ReportUtilizer reportUtilizer;

    public Processor(int cmdCode, String description) {
        this.cmdCode = cmdCode;
        this.description = description;

        this.requestValidator = () -> true;
        this.requestor = () -> 0;
        this.responseValidator = response -> 0;
        this.responseUtilizer = response -> {};
    }

    public Processor(int cmdCode, String description, RequestValidator requestValidator, Requestor requestor,
                     boolean needNotifyRequestor, ResponseValidator responseValidator, ResponseUtilizer responseUtilizer,
                     ReportUtilizer reportUtilizer) {
        this.cmdCode = cmdCode;
        this.description = description;
        this.requestValidator = requestValidator;
        this.requestor = requestor;
        this.needNotifyRequestor = needNotifyRequestor;
        this.responseValidator = responseValidator;
        this.responseUtilizer = responseUtilizer;
        this.reportUtilizer = reportUtilizer;
    }

    public int getCmdCode() {
        return cmdCode;
    }

    public void setCmdCode(int cmdCode) {
        this.cmdCode = cmdCode;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public RequestValidator getRequestValidator() {
        return requestValidator;
    }

    public void setRequestValidator(RequestValidator requestValidator) {
        this.requestValidator = requestValidator;
    }

    public Requestor getRequestor() {
        return requestor;
    }

    public void setRequestor(Requestor requestor) {
        this.requestor = requestor;
    }

    public boolean isNeedNotifyRequestor() {
        return needNotifyRequestor;
    }

    public void setNeedNotifyRequestor(boolean needNotifyRequestor) {
        this.needNotifyRequestor = needNotifyRequestor;
    }

    public ResponseValidator getResponseValidator() {
        return responseValidator;
    }

    public void setResponseValidator(ResponseValidator responseValidator) {
        this.responseValidator = responseValidator;
    }

    public ResponseUtilizer getResponseUtilizer() {
        return responseUtilizer;
    }

    public void setResponseUtilizer(ResponseUtilizer responseUtilizer) {
        this.responseUtilizer = responseUtilizer;
    }

    public ReportUtilizer getReportUtilizer() {
        return reportUtilizer;
    }

    public void setReportUtilizer(ReportUtilizer reportUtilizer) {
        this.reportUtilizer = reportUtilizer;
    }

    public interface RequestValidator {
        boolean validate();
    }
    public interface Requestor {
        int request();
    }
    public interface ResponseValidator {
        int validate(CacheNode response);
    }
    public interface ResponseUtilizer {
        void utilize(CacheNode response);
    }
    public interface ReportUtilizer {
        void utilize(CacheNode report);
    }
}